package com.example.ebel.ticker;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;


public class MatchDetailsLayout extends LinearLayout {

	private LinearLayout mLL;
	private Button mFB1, mFB2, mBack;
	
	public MatchDetailsLayout(Context context) {
		super(context);
		
		//instantiate xml layout
		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.matchdetails, this);

		mBack = (Button) this.findViewById(R.id.back_button);		
		mBack.setOnClickListener(new View.OnClickListener() {
	       	public void onClick(View v) {

	       			Intent myIntent = new Intent(v.getContext(), EBELTicker.class);
	                v.getContext().startActivity(myIntent); 

	            }
	        });
		
		
		//set references and onClickListeners for filter buttons
		mFB1 = (Button) this.findViewById(R.id.filter1_button);
		mFB1.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View v){

            	//TBD
            	mFB1.setText("x");
            	mFB1.setVisibility(View.GONE);
            }
		});

		mFB2 = (Button) this.findViewById(R.id.filter2_button);
		mFB2.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View v){

            	//TBD
            	mFB2.setText("x");
            	mFB2.setVisibility(View.GONE);
            }
		});

		//set reference for entries root element
		mLL = (LinearLayout) this.findViewById(R.id.entries_ll);

		//TBD
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
		mLL.addView(new MatchDetailsEntryLayout(context, this, "RBS", "2 Min", "43:56 - 45:56", "72 - ZIDAN Andrej (Boarding)"));
	}
	
	public void setFilter(String str){
		//TBD
		if(mFB1.getVisibility() != View.VISIBLE){
			mFB1.setText(str);
			mFB1.setVisibility(View.VISIBLE);			
		}
		else if(mFB2.getVisibility() != View.VISIBLE){
			mFB2.setText(str);
			mFB2.setVisibility(View.VISIBLE);
		}
	}
}